home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 SRC / Mac / Modules / fm / fmscan.py < prev    next >
Text File  |  1996-04-12  |  1KB  |  48 lines

  1. # Scan an Apple header file, generating a Python file of generator calls.
  2.  
  3. import addpack
  4. addpack.addpack(':tools:bgen:bgen')
  5. from scantools import Scanner
  6. from bgenlocations import TOOLBOXDIR
  7.  
  8. LONG = "Fonts"
  9. SHORT = "Fm"
  10.  
  11. def main():
  12.     input = "Fonts.h"
  13.     output = SHORT + "gen.py"
  14.     defsoutput = TOOLBOXDIR + LONG + ".py"
  15.     scanner = MyScanner(input, output, defsoutput)
  16.     scanner.scan()
  17.     scanner.close()
  18.     print "=== Done scanning and generating, now importing the generated code... ==="
  19.     exec "import " + SHORT + "support"
  20.     print "=== Done.  It's up to you to compile it now! ==="
  21.  
  22. class MyScanner(Scanner):
  23.  
  24.     def destination(self, type, name, arglist):
  25.         classname = "Function"
  26.         listname = "functions"
  27.         return classname, listname
  28.  
  29.     def makeblacklistnames(self):
  30.         return [
  31.             "OutlineMetrics",    # Too complicated
  32.             ]
  33.  
  34.     def makeblacklisttypes(self):
  35.         return [
  36.             "FMInput_ptr",    # Not needed for now
  37.             "FMOutPtr",        # Ditto
  38.             ]
  39.  
  40.     def makerepairinstructions(self):
  41.         return [
  42.             ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
  43.             ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
  44.             ]
  45.             
  46. if __name__ == "__main__":
  47.     main()
  48.